package model.core;

import model.ability.Ability;
import model.ability.InteractiveAbility;
import model.ability.MapAbility;
import utility.BidirectionalMap;

public class AbilitiesLibrary {
	private BidirectionalMap<String, Ability> library = new BidirectionalMap<String, Ability>();
	private BidirectionalMap<String, InteractiveAbility> interactiveLibrary = new BidirectionalMap<String, InteractiveAbility>();
	private BidirectionalMap<String, MapAbility> mapLibrary = new BidirectionalMap<String, MapAbility>();
	private static AbilitiesLibrary abilitiesLibrary = null;
	
	private AbilitiesLibrary(){
	
	}
	
	public static AbilitiesLibrary getInstance(){
		if (abilitiesLibrary == null){
			abilitiesLibrary = new AbilitiesLibrary();
		}
		return abilitiesLibrary;
	}
	
	public Ability getAbility(String name){
		return library.getFromSecondSet(name).clone();
	}
	
	public InteractiveAbility getInteractiveAbility(String name){
		return (InteractiveAbility) interactiveLibrary.getFromSecondSet(name).clone();
	}
	
	public MapAbility getMapAbility(String name){
		return (MapAbility) mapLibrary.getFromSecondSet(name).clone();
	}

	public String getName(Ability ab){
		return library.getFromFirstSet(ab);
	}
	
	public void put(String name, Ability ab){
		library.put(name, ab);
	}
	
	public void putInteractive(String name, InteractiveAbility ab){
		this.put(name, ab);
		interactiveLibrary.put(name, ab);
	}
	
	public void putMap(String name, MapAbility ab){
		this.put(name, ab);
		mapLibrary.put(name, ab);
	}
}
